package com.lut.reservation.util;

import com.lut.reservation.bean.Result;

public class ResultUtil {

  public static Result<Void> success() {
    final Result<Void> result = new Result<>();
    result.setCode(2000);
    result.setMessage("success");
    return result;
  }

  public static <T> Result<T> success(String message, T data) {
    final Result<T> result = new Result<>();
    result.setCode(2000);
    result.setData(data);
    result.setMessage(message);
    return result;
  }

  public static <T> Result<T> success(T data) {
    final Result<T> result = new Result<>();
    result.setCode(2000);
    result.setData(data);
    result.setMessage("success");
    return result;
  }

  public static Result<Void> success(Integer code, String message) {
    final Result<Void> result = new Result<>();
    result.setCode(code);
    result.setMessage(message);
    return result;
  }

  public static <T> Result<T> success(Integer code, String message, T data) {
    final Result<T> result = new Result<>();
    result.setCode(code);
    result.setMessage(message);
    result.setData(data);
    return result;
  }

  public static <T> Result<T> fail() {
    final Result<T> result = new Result<>();
    result.setCode(1000);
    result.setMessage("fail");
    return result;
  }

  public static <T> Result<T> fail(String message) {
    final Result<T> result = new Result<>();
    result.setCode(1000);
    result.setMessage(message);
    return result;
  }
}
